class BabyRock extends egret.DisplayObjectContainer {

    constructor() {
        super();
        this.init();
    }

    public static STATE_NORMAL = 'nomarl';
    public static STATE_JUMP = 'jump';
    private state = 'nomarl';
    private JUMP_OFFSET:number = -14;
    private normal_texture:egret.Texture = RES.getRes('baby_rock_normal_png');
    private jump_texture:egret.Texture = RES.getRes('baby_rock_jump_png');
    public babyRockBitmap:egret.Bitmap = new egret.Bitmap();
    private timer:egret.Timer = new egret.Timer(200, 1);
 
    public init() {
         this.babyRockBitmap.texture = this.normal_texture;
         this.addChild(this.babyRockBitmap);
         this.timer.addEventListener(egret.TimerEvent.TIMER, this.stand, this);
    }

    public jump() {
        this.babyRockBitmap.texture = this.jump_texture;
        this.babyRockBitmap.y = (this.JUMP_OFFSET * Math.random() + this.JUMP_OFFSET) / 2;
        this.timer.start()
    }

    public stand() {
        this.babyRockBitmap.texture = this.normal_texture;
        this.babyRockBitmap.y = 0;
        this.timer.reset();
    }
}